import request from "@/router/axios";

export const getList = (current, size, params) => {
  return request({
    url: "/api/hg-quality/procreate/page",
    method: "get",
    params: {
      ...params,
      current,
      size
    }
  });
};

// 选择问题来源为供应商时，发生场所的数据下拉的接口
export const supplier = row => {
  return request({
    url: "/api/blade-supplier-management/supplierinfo/supplierList",
    method: "get",
    data: row
  });
};

// 数据来源为客户
export const customer = row => {
  return request({
    url: "/api/hg-public/customer/list",
    method: "get",
    data: row
  });
};

export const add = data => {
  return request({
    url: "/api/hg-quality/procreate/save",
    method: "post",
    data: data
  });
};

export const update = data => {
  return request({
    url: "/api/hg-quality/procreate/update",
    method: "post",
    data: data
  });
};

export const getDetail = params => {
  return request({
    url: "/api/hg-quality/procreate/detail",
    method: "get",
    params: {
      ...params
    }
  });
};

export const remove = ids => {
  return request({
    url: "/api/hg-quality/procreate/remove",
    method: "post",
    params: {
      ids
    }
  });
};

// 产品编码模糊搜索
export const getProductByProductNo = materialNo => {
  return request({
    url: "/api/hg-public/productdrawingchange/materialByMaterialNo",
    method: "get",
    params: {
      materialNo
    }
  });
};

// 获取所有生产线
export const getProduceline = () => {
  return request({
    url: "/api/hg-public/produceline/list",
    method: "get"
  });
};

// 通过生产线获取车间工序
export const getPrdprocedure = (produceLineId) => {
  return request({
    url: "/api/hg-public/prdprocedure/list",
    method: "get",
    params: {
      produceLineId
    }
  });
};

// 通过生产日期和产品编号获取产品批次号
export const getProductBatch = params => {
  return request({
    url: "/api/hg-quality/procreate/getProductBatch",
    method: "get",
    params: {
      ...params
    }
  });
};

// 结案确认详情
export const getProconfirmDetail = params => {
  return request({
    url: "/api/hg-quality/proconfirm/detail",
    method: "get",
    params
  });
};

// 结案确认审批显示解决办法
export const getProconfirmDetailApprove = params => {
  return request({
    url: "/api/hg-quality/prolist/approveDetail",
    method: "get",
    params
  });
};

// 结案确认
export const getProconfirm = (data,type) => {
  return request({
    url: `/api/hg-quality/proconfirm/${type}`,
    method: "post",
    data
  });
};


// 结案确认启动流程
export const proconfirmStart = id => {
  return request({
    url: "/api/hg-quality/proconfirm/start-process",
    method: "post",
    params: {
      id
    }
  });
};

// 启动流程
export const startProcess = id => {
  return request({
    url: "/api/hg-quality/procreate/start-process",
    method: "post",
    params: {
      id
    }
  });
};

// 根据产品获取车间生产线工序
export const shopLineProduce = productId => {
  return request({
    url: "/api/hg-public/prdprocedure/list",
    method: "get",
    params: {
      productId
    }
  });
};
